// pages/home/business/business.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  gridBtn(e) {
    console.log(e.currentTarget.dataset.num)
    if (e.currentTarget.dataset.num == 9) {
      this.chanchu();
    } else if (e.currentTarget.dataset.num == 10) {
      this.chuhuo();
    } else if (e.currentTarget.dataset.num == 16) {
      this.userchu();
    } else if (e.currentTarget.dataset.num == 17) {
      this.monthchu();
    } else if (e.currentTarget.dataset.num == 60) {
      this.myorder();
    } else if (e.currentTarget.dataset.num == 29) {
      this.goalreachmonth();
    } else if (e.currentTarget.dataset.num == 30) {
      this.goalreachyear();
    } else if (e.currentTarget.dataset.num == 31) {
      this.preproduct();
    } else if (e.currentTarget.dataset.num == 34) {
      this.allpreproduct();
    } else if (e.currentTarget.dataset.num == 36) {
      this.userincrease();   
    } else if (e.currentTarget.dataset.num == 41) {
      this.useractive();   
    } else if (e.currentTarget.dataset.num == 39) {
      this.goalreachmonthpeo();
    } else if (e.currentTarget.dataset.num == 40) {
      this.goalreachyearpeo();
    } else if (e.currentTarget.dataset.num == 43) {
      this.usersection();
    } else if (e.currentTarget.dataset.num == 55) {
      this.purreserve();
    } else if (e.currentTarget.dataset.num == 57) {
      this.aftreserve();
    } else if (e.currentTarget.dataset.num == 80) {
      this.orderdetail();
    } else if (e.currentTarget.dataset.num == 84) {
      this.goalreachmonthtqtb();
    } else {
      wx.showToast({
        title: '暂未开放！',
        icon: 'error'
      })
    }
  },

  // 订单明细相关
  orderdetail(){
    wx.navigateTo({
      url: '../business/orderdetail/orderdetail'
    })
  },

  // 已备待出清单
  aftreserve(){
    wx.navigateTo({
      url: '../storage/aftreserve/aftreserve'
    })
  },

  // 成品待备概况
  purreserve(){
    wx.navigateTo({
      url: '../storage/purreserve/purreserve'
    })
  },

  // 订单量区间分析
  usersection(){
    wx.navigateTo({
      url: './usersection/usersection'
    })
  },

  // 客户订单待生产明细
  preproduct(){
    wx.navigateTo({
      url: '../product/preproduct/preproduct'
    })
  },

  // 客户订单待生产汇总
  allpreproduct(){
    wx.navigateTo({
      url: '../product/allpreproduct/allpreproduct'
    })
  },

  // 收单产出货概况
  chanchu() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './chanchu/chanchu',
    })
  },

  // 日收单产出货概况
  chuhuo() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './chuhuo/chuhuo',
    })
  },

  // 客户每日出货概况
  userchu() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './userchu/userchu',
    })  
  },

  // 月收单产出货概况
  monthchu() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './monthchu/monthchu',
    })
  },   

  // 客户增长情况
  userincrease() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './userincrease/userincrease',
    })
  },

  // 客户活跃情况
  useractive() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './useractive/useractive',
    })
  },

  // 我的订单
  myorder() {
    this.clickSubscribeMessage();
    // wx.navigateTo({
    //   url: '../userorder/order/order',
    // })
    wx.navigateTo({
      url: '/template/company/neworder/neworder',
    })
  },

  // 月度达成-部门
  goalreachmonth() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './goalreachmonth/goalreachmonth',
    })
  },   

  // 月度达成-部门
  goalreachmonthtqtb() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './goalreachmonthtqtb/goalreachmonthtqtb',
    })
  },

  // 月度达成-业务员
  goalreachmonthpeo() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './goalreachmonthpeo/goalreachmonthpeo',
    })
  },

  // 年度达成-部门
  goalreachyear() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './goalreachyear/goalreachyear',
    })
  },

  // 年度达成-业务员
  goalreachyearpeo() {
    this.clickSubscribeMessage();
    wx.navigateTo({
      url: './goalreachyearpeo/goalreachyearpeo',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.showLoading({
      title: '加载中',
      mask: true,
      complete: function(res) {
        wx.hideLoading()
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },
  //在用户必点的地方，调用订阅消息方法
  clickSubscribeMessage(){
    let flag = wx.getStorageSync('checkPushFlag') || false;
    console.log(flag, "缓存触发结果");
    //订阅消息
    if(flag){
      var tempId = getApp().globalData.workTaskTemplateId;
      wx.requestSubscribeMessage({
        tmplIds: tempId,
        success(res){
          console.log(res);
        }
      })
    }
  }
})